package com.slife.serial.utils;




import org.springframework.beans.factory.annotation.Value;

import org.springframework.core.io.Resource;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

//使用@Value注解




public class FileUtils {

    @Value(value="classpath:default.json")
    private Resource resource;

    public static String getContent(InputStream inputStream){

//        resource.getInputStream()


        BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
        StringBuffer message=new StringBuffer();
        String line = null;
        while(true) {
            try {
                if (!((line = br.readLine()) != null)) break;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            message.append(line);
        }
        String defaultString=message.toString();
        String result=defaultString.replace("\r\n", "").replaceAll(" +", "");
        return result;
    }
}
